<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!--360浏览器优先以webkit内核解析-->
    <meta name="renderer" content="webkit">
    <title>添加和编辑栏目</title>

 <style type="text/css">
    *{
      font-size:14px;
      margin: 0px;
      padding: 0px; 
    }
    ul{
      list-style-type: none;
      width: 100%;
    }
    body{
      padding-top: 50px;
      height: auto;
      width:100%;
      min-height:700px;
      background:url(image/content_bg.jpg);
      background-repeat: no-repeat;
      background-size: 100% 100%;
    }
    .left_div{
      height: auto;
      width:17%;
      min-height:400px;
      float:left;    
    }
    .right_div{
       float: right;
       min-height:450px;
       width:82%;
       border-left: 1px solid #000;
    }
    .inner_ul{
      clear: both;
      margin: 30px auto;
      width:70%;
      min-height: 200px;
      overflow: hidden;
      word-spacing: 2px;
    }
    .parent{
        min-height:20px;
        width: 100%;
    }
   .parent img{
      float: left;
      height: 14px;
      width:20px;
      margin-right: 5px;
      position:relative;
      top:5px;
    }
    .parent a{
        text-decoration: none;
        line-height: 20px;
        color: #000;
        display: block;
        overflow: hidden;
        text-overflow:ellipsis;
        white-space:nowrap;
    } 
    .hidden{
      display: none;
      margin-left:25%;
    }
    .parent li{
        width:100%;
        display: block;
        overflow: hidden;
        text-overflow:ellipsis;
        white-space:nowrap;
        color: red;
        cursor: pointer;
    }
   
    li span:hover{
       color: blue;
   }
    .secondclick{     
      position: relative;
      left: 25px;
    }
    .secondclick span{
      color:red;
    }
    .add{
      width: 100%;
      height: 30px;
      padding-left:5px;
      margin-bottom:10px;
      margin-top: 10px;
    }
    table{
       width: 100%;
       table-layout: fixed;

    }
    th,td{
       height: 25px;
       font-size: 13px;
       overflow: hidden; 
       white-space: nowrap; 
       text-overflow: ellipsis;
    }
     td:hover{
      text-overflow:inherit; 
      overflow: visible;
    }
    .time{
        width:15%;
        text-align: center;
    }
     .title{
        width:30%;
        text-align: center;
    }
     .author{
        width:9%;
        text-align: center;
    }
     .state{
        width:7%;  
        text-align: center;     
    }
     .operation{
        width:14%;
        text-align: center;
    }
    .text_center{
      text-align: center;
    }

 </style>
</head>
<body>

      <div class="all">
           <div class="left_div">
                 <ul class="inner_ul">
                 </ul>
              
           </div>
           <div class="right_div">
              <div class="add"><a id="href" href="control.html">添加内容</a></div>
              <div class="table">
                    <table>
                           <thead>
                                <tr id="firstline">
                                </tr>
                           </thead>
                           <tbody>
                              
                           </tbody>

                    </table>
              </div>
             
         </div>
      </div>
<script type="text/javascript" src="js/jquery.min.js"></script> 
<script type="text/javascript" src="../public/js/serverIp.js"></script>
<script type="text/javascript">
     $(function(){      
      
       $.post(serverIp+"/Scauaie.com/artical/coumns/show",null,function(data){
            var dataobj=JSON.parse(data);
            $.each(dataobj,function(index,value){
                   $(".inner_ul").append("<li class='parent "+index+"' data='"+value.id+"' order='"+value.order+"' modelId='"+value.modelId+"'></li>");
                   $("."+index).append("<a href='javascript:;'><img src='image/narrow_forright.png'><span>"+value.name+"</span></a>");
                   $("."+index).append("<ul class='ul 1000'></ul>");
            })

             var clicknumber=100;
             var ultime=1000;
             var ulinstead;
             function click(){
                   var parent=$(this).parent();
                   var self=$(this);
                   var line=self.find("span").html().match(/[\-]*/gi);

                   var datastr="id="+parent.attr("data");
                   $.post(serverIp+"/Scauaie.com/artical/coumns/showchild",datastr,function(data){
                        var dataobj=JSON.parse(data);
                        ulinstead=ultime;
                        if(ultime!=1000){
                            var arr=self.next().attr("class").split(" ");
                            ultime=arr[1];
                        }
                        $.each(dataobj,function(index,value){
                             var index=index-100;
                             parent.find("."+ultime).append("<li class='"+clicknumber+' '+index+"' data='"+value.id+"' order='"+value.order+"' modelId='"+value.modelId+"'><a href='javascript:;' class='secondclick'><span>-"+line[0]+value.name+"</span></a></li>");
                             $("."+ultime).find("."+index).append("<ul class='ul "+(--ulinstead)+"'></ul>");
                        })
                        ultime=ulinstead;
                        parent.find("."+clicknumber).find("a").bind("click",click);
                        parent.find("."+clicknumber).find("a").trigger("click");
                        clicknumber++;

                   },"html");
                   $(this).unbind("click");
                   $(this).bind("click",fill);
             }

             function fill(){   
              
                   var currentId=$(this).parent().attr("data");
                   var modelId=$(this).parent().attr("modelId");
                   var datastr="type=COLUMN&bool=false&columnId="+currentId+"&modelId="+modelId;
                   var arr=$("#href").attr("href").split("?");
                   var href=arr[0]+"?"+modelId+"&"+currentId+"&add";  
                   $("#href").attr("href",href);                  
                   if(modelId=="1"){
                        window.location.href=href;

                   }else{

                       $.post(serverIp+"/Scauaie.com/artical/showAll",datastr,function(data){

  
                            $("#firstline").empty();
                            var dataobj=JSON.parse(data);
                            if(modelId==2){
                                   $("#firstline").append(" <th class='time'>发送时间</th><th class='title'>内容标题</th><th class='author'>作者</th><th <td class='author'>状态</th><th class='operation'>操作</th>");
                                    $("tbody").empty();
                                    $.each(dataobj,function(index,value){
                                        index=index+5000;
                                        $("tbody").append("<tr class='"+index+"'></tr>");
                                        $("."+index).append("<td class='text_center'>"+value.releaseDate+"</td><td  class='article' modelId='2' id='"+value.id+"'>"+value.title+"</td><td class='text_center'>"+value.author+"</td><td class='text_center'><input id='checkbox' type='checkbox' disabled></td><td class='text_center' ><a href='javascript:;' class='update'>编辑</a> | <a href='javascript:;' class='delete'>删除</a></td>");
                                        if(value.status==true){
                                           $("."+index).find('#checkbox').attr("checked",true); 
                                         }
                                    })
                            }else if(modelId==3){
                                    $("#firstline").append(" <th class='time'>发送时间</th><th class='title'>内容标题</th><th class='author'>编辑</th><th <td class='author'>状态</th><th class='operation'>操作</th>");
                                    $("tbody").empty();
                                    $.each(dataobj,function(index,value){
                                      index=index+5000;
                                      $("tbody").append("<tr class='"+index+"'></tr>");
                                      $("."+index).append("<td class='text_center'>"+value.releaseDate+"</td><td class='article' modelId='3' id='"+value.download_id+"'>"+value.title+"</td><td class='text_center'>"+value.editor+"</td><td class='text_center'><input id='checkbox' type='checkbox' disabled></td><td class='text_center' ><a href='javascript:;' class='update'>编辑</a> | <a href='javascript:;' class='delete'>删除</a></td>");
                                      if(value.status==true){
                                         $("."+index).find('#checkbox').attr("checked",true); 
                                       }
                                    })

                            }else if(modelId==4){
                                   $("#firstline").append(" <th class='time'>发送时间</th><th class='title'>内容标题</th><th class='author'>第一作者</th><th <td class='author'>状态</th><th class='operation'>操作</th>");
                                
                                    $("tbody").empty();
                                    $.each(dataobj,function(index,value){
                                      index=index+5000;
                                      $("tbody").append("<tr class='"+index+"'></tr>");
                                      $("."+index).append("<td class='text_center'>"+value.releaseDate+"</td><td class='article'  modelId='4' id='"+value.work_id+"'>"+value.title+"</td><td class='text_center'>"+value.firstAuthor+"</td><td class='text_center'><input id='checkbox' type='checkbox' disabled></td><td class='text_center' ><a href='javascript:;' class='update'>编辑</a> | <a href='javascript:;' class='delete'>删除</a></td>");
                                      if(value.status==true){
                                         $("."+index).find('#checkbox').attr("checked",true); 
                                       }
                                    })
                            }else if(modelId==5){
                                   $("#firstline").append(" <th class='time'>姓名</th><th class='time'>部门</th><th class='time'>职务</th><th class='time'>籍贯</th><th class='time'>专业</th><th class='operation'>操作</th>");
                                   $("tbody").empty();
                                    $.each(dataobj,function(index,value){
                                      index=index+5000;
                                      $("tbody").append("<tr class='"+index+"'></tr>");
                                      $("."+index).append("<td class='text_center article'  modelId='5' id='"+value[0]+"'>"+value[1]+"</td><td class='text_center'>"+value[2]+"</td><td class='text_center'>"+value[3]+"</td><td class='text_center'>"+value[4]+"</td><td class='text_center'>"+value[5]+"</td></td><td class='text_center' ><a href='javascript:;' class='update'>编辑</a> | <a href='javascript:;' class='delete'>删除</a></td>");
                                    })

                            }else{
                                  $("#firstline").append(" <th class='time'>栏目ID</th><th class='title'>图片地址<th class='operation'>操作</th>");
                                   $("tbody").empty();
                                    $.each(dataobj,function(index,value){
                                      index=index+5000;
                                      $("tbody").append("<tr class='"+index+"'></tr>");
                                      $("."+index).append("<td class='author'>"+value.columnId+"</td><td  class='article'  modelId='6' id='"+value.pictureArticle_id+"'>"+value.pictureUrl+"</td><td class='author' ><a href='javascript:;' class='update'>编辑</a> | <a href='javascript:;' class='delete'>删除</a></td>");
                                    })

                            }

                            $(".delete").click(function(){
                                   var isdelete=confirm("删除操作不可恢复，确定要删除吗？");
                                   var article=$(this).parent().prevAll(".article");
                                   var datastr="modelId="+article.attr("modelId")+"&id="+article.attr("id");
                                   var thisobj=$(this);
                                   if(isdelete){
                                        $.post(serverIp+"/Scauaie.com/artical/delete",datastr,function(data){
                                             var dataobj=JSON.parse(data);
                                             if(dataobj.bool=="true"){
                                                 thisobj.parent().parent().remove();
                                             }
                                        },"html")
                                   }
                              })

                              $(".update").click(function(){

                                 var article=$(this).parent().prevAll(".article");
                                 var modelId=article.attr("modelId");
                                 var id=article.attr("id");
                                 var arr=$("#href").attr("href").split("&");
                                 window.location.href=arr[0]+"&"+arr[1]+"&edit&"+id;                        
                              })
                       },"html")     
                   }    
                  
             }
             $(".parent").find("a").bind("click",click);
             $(".parent").find("a").trigger("click");

       },"html")

  
     

  })
</script>
</body>

</html>